package com.hdax.dm.dto;

import com.hdax.dm.common.exception.DmException;

public class DtoUtil<T> {

    public static<T> CommonResponse returnSuccess(String msg,T data){
        /*CommonResponse commonResponse = CommonResponse.builder()
                .msg(msg)
                .data(data)
                .build();
        return commonResponse;*/
        return new CommonResponse(data,msg);
    }

    public static CommonResponse returnFail(String msg,String code){
//        return new CommonResponse(msg,code);
        CommonResponse commonResponse = CommonResponse.builder()
                .msg(msg).errorCode(code).build();
        return commonResponse;
    }

    public static CommonResponse returnFail(DmException exception){
        return new CommonResponse(exception.getErrorMsg(),exception.getErrorCode());
    }

}
